import request from "@/utils/request";

/**
 * 搜索
 * @param {string} name
 * @returns
 */

export function userSearch(name) {
    return request.post(`/userEntity/userSearch?name=${name}`);
}

/**
 * 注册
 * @param {string} account
 * @param {string} password
 * @param {string} name
 * @param {string} code
 * @returns
 */
export function userRegister(account, password, name, code) {
    return request.post(`/userEntity/userRegister?account=${account}&password=${password}&name=${name}&code=${code}`);
}

/**
 * 登录
 * @param {string} account
 * @param {string} password
 * @param {string} code
 * @returns
 */
export function userLogin(account, password, code) {
    return request.post(`/userEntity/userLogin?account=${account}&password=${password}&code=${code}`);
}

/**
 * 列表分页
 * @param {string} page
 * @param {string} pageSize
 * @returns
 */
export function userListPage(page, pageSize) {
    return request.post(`/userEntity/userListPage?page=${page}&pageSize=${pageSize}`);
}

/**
 * 获取
 * @param {string} id
 * @returns
 */
export function userId(id) {
    return request.post(`/userEntity/userId?id=${id}`);
}

/**
 * 找回密码
 * @param {string} account
 * @param {string} password
 * @param {string} code
 * @returns
 */
export function userForget(account, password, code) {
    return request.post(`/userEntity/userForget?account=${account}&password=${password}&code=${code}`);
}

/**
 * 编辑
 * @param {object} params 用户表
 * @param {number} params.id 主键
 * @param {string} params.account 账号
 * @param {string} params.password 密码
 * @param {string} params.avatar 头像
 * @param {string} params.name 姓名
 * @param {string} params.sex 性别
 * @param {string} params.birth 生日
 * @param {string} params.phone 电话
 * @param {string} params.address 地址
 * @param {number} params.role 角色
 * @param {object} params.current 创建时间
 * @returns
 */
export function userEditor(params) {
    return request.post(`/userEntity/userEditor`, params);
}

/**
 * 删除
 * @param {string} id
 * @returns
 */
export function userDelete(id) {
    return request.post(`/userEntity/userDelete?id=${id}`);
}

/**
 * 修改密码
 * @param {string} id
 * @param {string} oldPwd
 * @param {string} newPwd
 * @returns
 */
export function userChangePass(id, oldPwd, newPwd) {
    return request.post(`/userEntity/userChangePass?id=${id}&oldPwd=${oldPwd}&newPwd=${newPwd}`);
}

/**
 * 新增
 * @param {object} params User
 * @param {string} params.account
 * @param {string} params.password
 * @param {string} params.avatar
 * @param {string} params.name
 * @param {string} params.sex
 * @param {string} params.birth
 * @param {string} params.phone
 * @param {string} params.address
 * @param {number} params.role
 * @returns
 */
export function userAppend(params) {
    return request.post(`/userEntity/userAppend`, params);
}

/**
 * 列表
 * @returns
 */
export function userList() {
    return request.get(`/userEntity/userList`);
}
